package com.ruoyi.teaching.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.teaching.domain.YaStageTaskSubmit;
import com.ruoyi.teaching.service.IYaStageTaskSubmitService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 学生任务提交情况Controller
 * 
 * @author ruoyi
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/stage_task_submit")
public class YaStageTaskSubmitController extends BaseController
{
    @Autowired
    private IYaStageTaskSubmitService yaStageTaskSubmitService;

    /**
     * 查询学生任务提交情况列表
     */
    @RequiresPermissions("teaching:stage_task_submit:list")
    @GetMapping("/list")
    public TableDataInfo list(YaStageTaskSubmit yaStageTaskSubmit)
    {
        startPage();
        List<YaStageTaskSubmit> list = yaStageTaskSubmitService.selectYaStageTaskSubmitList(yaStageTaskSubmit);
        return getDataTable(list);
    }

    /**
     * 导出学生任务提交情况列表
     */
    @RequiresPermissions("teaching:stage_task_submit:export")
    @Log(title = "学生任务提交情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YaStageTaskSubmit yaStageTaskSubmit)
    {
        List<YaStageTaskSubmit> list = yaStageTaskSubmitService.selectYaStageTaskSubmitList(yaStageTaskSubmit);
        ExcelUtil<YaStageTaskSubmit> util = new ExcelUtil<YaStageTaskSubmit>(YaStageTaskSubmit.class);
        util.exportExcel(response, list, "学生任务提交情况数据");
    }

    /**
     * 获取学生任务提交情况详细信息
     */
    @RequiresPermissions("teaching:stage_task_submit:query")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
    {
        return success(yaStageTaskSubmitService.selectYaStageTaskSubmitByTaskId(taskId));
    }

    /**
     * 新增学生任务提交情况
     */
    @RequiresPermissions("teaching:stage_task_submit:add")
    @Log(title = "学生任务提交情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YaStageTaskSubmit yaStageTaskSubmit)
    {
        return toAjax(yaStageTaskSubmitService.insertYaStageTaskSubmit(yaStageTaskSubmit));
    }

    /**
     * 修改学生任务提交情况
     */
    @RequiresPermissions("teaching:stage_task_submit:edit")
    @Log(title = "学生任务提交情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YaStageTaskSubmit yaStageTaskSubmit)
    {
        return toAjax(yaStageTaskSubmitService.updateYaStageTaskSubmit(yaStageTaskSubmit));
    }

    /**
     * 删除学生任务提交情况
     */
    @RequiresPermissions("teaching:stage_task_submit:remove")
    @Log(title = "学生任务提交情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(yaStageTaskSubmitService.deleteYaStageTaskSubmitByTaskIds(taskIds));
    }
}
